package com.miplus.ccrm.report.service;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;

@Service
public class StatusConversionService {
    private final Map<String, String> lineStatusMap = new HashMap<>();
    private final Map<String, String> acdStatusMap = new HashMap<>();
    private final Map<String, String> reasonMap = new HashMap<>();
    public StatusConversionService() {
        // 初始化线路状态映射
        lineStatusMap.put("connect", "通话中");
        lineStatusMap.put("hold", "保留中");
        lineStatusMap.put("consult", "咨询中");
        lineStatusMap.put("transfer", "转接中");
        lineStatusMap.put("conference", "会议中");
        lineStatusMap.put("ring", "振铃中");
        lineStatusMap.put("alerting", "振铃中");
        lineStatusMap.put("dial", "拨号中");
        lineStatusMap.put("compconf", "会议完成");
        lineStatusMap.put("comptrans", "转接完成");
        // 初始化ACD状态映射
        acdStatusMap.put("login", "签入");
        acdStatusMap.put("logout", "签出");
        acdStatusMap.put("ready", "就绪");
        acdStatusMap.put("notready", "离席");
        acdStatusMap.put("pending", "离席中");
        acdStatusMap.put("work", "工作中");
        // 初始化Reason映射
        reasonMap.put("128", "外呼");
    }
    // 转换线路状态
    public String convertLineStatus(String status) {
        return getOrDefault(lineStatusMap, status);
    }
    // 转换ACD状态
    public String convertAcdStatus(String status) {
        return getOrDefault(acdStatusMap, status);
    }
    // 转换Reason
    public String convertReason(String reason) {
        return getOrDefault(reasonMap, reason);
    }
    // 检查线路状态
    public boolean isCheckLineState(String status) {
        return "ready".equalsIgnoreCase(status) || "notready".equalsIgnoreCase(status);
    }
    // 通用获取映射值方法
    private String getOrDefault(Map<String, String> map, String key) {
        return key != null ? map.getOrDefault(key.toLowerCase(), "") : "";
    }
}
